#include "../../include/RssTest.h"
#include "../../include/PageLibPreprocessor.h"
#include "../../include/Configuration.h"
#include "../../include/Logger.h"
#include <chrono>

int main(void) {
    // 获取程序开始时间点
    auto start = std::chrono::high_resolution_clock::now();

    string ch_xml_path = Configuration::getInstance()->getConfigValue("CN_XML_PATH");
    string invert_path = Configuration::getInstance()->getConfigValue("INVERT_INDEX_TABLE_PATH");
    string pagelib_path = Configuration::getInstance()->getConfigValue("PAGELIB_PATH");
    string offset_path = Configuration::getInstance()->getConfigValue("OFFSET_PATH");
    
    RSS_read rsstest(ch_xml_path);
    rsstest.read();

    //执行去重操作
    rsstest.removeSame();

    rsstest.store(pagelib_path, offset_path);

    //开始建立倒排索引库
    PageLibPreprocessor p1(rsstest._RSS);
    p1.Run(invert_path);

    // 获取程序结束时间点
    auto end = std::chrono::high_resolution_clock::now();
    // 计算程序执行时间
    std::chrono::duration<double> duration = end - start;
    double executionTime = duration.count();

    // 打印程序执行时间
    LogInfo("网页库文件生成执行耗时：%lf 秒", executionTime);
}
